import { Injectable } from '@nestjs/common'
import { VerRecordDto } from './dto/ver-record.dto'
import { VerRecord } from '@prisma/client'
import { BaseService } from '@/base/base.service'
import { PrismaBaseService } from '@/prisma-base/prisma-base.service'

@Injectable()
export class VerRecordService extends BaseService<VerRecord, VerRecordDto> {
  constructor(private readonly prismaBase: PrismaBaseService) {
    super('VerRecord')
  }

  async verifyRes(ver_id: string, houseResId: string) {
    await this.prismaBase.verRecord.update({
      where: {
        id: ver_id,
      },
      data: {
        ver_status: true,
      },
    })
    await this.prismaBase.houseRes.update({
      where: {
        id: houseResId,
      },
      data: {
        house_status: false,
      },
    })
    return '核销成功'
  }
}
